//
//  HNCareCardView.m
//  BestLearning
//
//  Created by 星道 on 17/9/21.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HNCareCardView.h"

@implementation HNCareCardView
{
    IBOutlet UIView *_content;
}



+ (instancetype)Show {

    return [[self alloc] init];
}

- (instancetype)init {

    self = [[[NSBundle mainBundle] loadNibNamed:[HNCareCardView description] owner:nil options:nil] lastObject];
    if (self) {

        self.frame = [UIScreen mainScreen].bounds;
        [[UIApplication sharedApplication].keyWindow addSubview:self];

        _content.hidden = NO;
        _content.alpha = 0;
        self.alpha = 0;

        [self Start];
    }
    return self;
}




- (void)Start {

    _content.transform = CGAffineTransformMakeScale(0.001, 0.001);

    [UIView animateWithDuration:0.3 animations:^{

        self.alpha = 1;
    } completion:^(BOOL finished) {
        _content.alpha = 1;

            [UIView animateWithDuration:0.3 animations:^{

                _content.transform = CGAffineTransformMakeScale( 1.4, 1.4);
            } completion:^(BOOL finished) {

                [UIView animateWithDuration:0.3 animations:^{

                    _content.transform = CGAffineTransformIdentity;
                }];
            }];
        }];
}



- (IBAction)Close:(UIButton *)sender {

    [UIView animateWithDuration:0.5 animations:^{

        self.alpha = 0;
    } completion:^(BOOL finished) {

        [self removeFromSuperview];
    }];
}

@end
